package hk.m4s.lr.repair.test.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import org.json.JSONArray;

import java.util.ArrayList;
import java.util.List;

import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.MaintenanceInfoModel;
import hk.m4s.lr.repair.test.model.projectModle;
import hk.m4s.lr.repair.test.views.InnerGridView;

/**
 * Created by qi.wang on 2017/3/16.
 */

public class LookRepaireListAdapter extends BaseAdapter {
    List<MaintenanceInfoModel> list = new ArrayList<>();
    List<projectModle> items;
    Context context;
    LayoutInflater inflater;
    PartslAdapter adapter;
    public LookRepaireListAdapter(Context context, List<MaintenanceInfoModel> data) {
        this.context = context;
        this.list = data;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.list_look_repaire, parent, false);
            holder.device_name = (TextView) convertView.findViewById(R.id.equ_titlte);
            holder.tipsName = (TextView) convertView.findViewById(R.id.tipsName);
            holder.finishtimeLayout=(LinearLayout) convertView.findViewById(R.id.finishtimeLayout);
            holder.equ_name= (TextView) convertView.findViewById(R.id.equ_name);
            holder.equ_statime= (TextView) convertView.findViewById(R.id.equ_statime);
            holder.equ_finishtime= (TextView) convertView.findViewById(R.id.equ_finishtime);
            holder.equ_work= (TextView) convertView.findViewById(R.id.equ_work);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        MaintenanceInfoModel businessModel = list.get(position);
        holder.device_name.setText(businessModel.getDeviceName());
        holder.equ_finishtime.setText(businessModel.getDescription());
        holder.equ_statime.setText(businessModel.getBeginTime());
        holder.equ_name.setText(businessModel.getUseClientName());
        holder.equ_work.setText(businessModel.getWorkbay());

        return convertView;
    }

    public static class ViewHolder {
        TextView device_name;
        TextView tipsName;
        TextView equ_name;
        TextView equ_statime;
        TextView equ_finishtime;
        TextView equ_work;
        ImageView up;
        LinearLayout finishtimeLayout;
        RelativeLayout nby_types;
    }
}
